//
//  DDesignerView.m
//  CarOfHome2
//
//  Created by 微 醺 on 15/9/29.
//  Copyright (c) 2015年 Frank. All rights reserved.
//

#import "DDesignerView.h"
#import "DDesignerModel.h"

@implementation DDesignerView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.img = [[UIImageView alloc] init];
//        self.img.backgroundColor = [UIColor cyanColor];
        [self addSubview:self.img];
        
        //毛玻璃
        self.blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
        self.blur.alpha = 0.9;
        [self addSubview:self.blur];
        
        self.personImg = [[UIImageView alloc] init];
//        self.personImg.backgroundColor = [UIColor yellowColor];
        [self addSubview:self.personImg];
        
        self.leftImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"zan"]];
//        self.leftImg.backgroundColor = [UIColor cyanColor];
        [self addSubview:self.leftImg];
        
        self.rightImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guanzhu"]];
//        self.rightImg.backgroundColor = [UIColor cyanColor];
        [self addSubview:self.rightImg];
        
        self.name = [[UILabel alloc] init];
//        self.name.backgroundColor = [UIColor greenColor];
        [self addSubview:self.name];
        
        self.introduce = [[UILabel alloc] init];
//        self.introduce.backgroundColor = [UIColor greenColor];
        [self addSubview:self.introduce];
        
        self.info = [[UILabel alloc] init];
//        self.info.backgroundColor = [UIColor greenColor];
        [self addSubview:self.info];
        
        self.leftZi = [[UILabel alloc] init];
//        self.leftZi.backgroundColor = [UIColor greenColor];
        self.leftZi.text = @"赞";
        [self addSubview:self.leftZi];
        
        self.zan = [[UILabel alloc] init];
//        self.zan.backgroundColor = [UIColor greenColor];
        [self addSubview:self.zan];
        
        self.rightZi = [[UILabel alloc] init];
//        self.rightZi.backgroundColor = [UIColor greenColor];
        self.rightZi.text = @"关注";
        [self addSubview:self.rightZi];
        
        self.attention = [[UILabel alloc] init];
//        self.attention.backgroundColor = [UIColor greenColor];
        [self addSubview:self.attention];
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    AppDelegate *dele = [[UIApplication sharedApplication]delegate];
    if (dele.isNight == 1) {
        self.backgroundColor = [UIColor blackColor];
        self.leftZi.textColor = [UIColor whiteColor];
        self.rightZi.textColor = [UIColor whiteColor];
        self.attention.textColor = [UIColor whiteColor];
        self.introduce.textColor = [UIColor whiteColor];
        self.zan.textColor = [UIColor whiteColor];
        self.name.textColor = [UIColor whiteColor];
        self.info.textColor = [UIColor whiteColor];
        
    }
    else{
        self.backgroundColor = [UIColor whiteColor];
        self.leftZi.textColor = [UIColor blackColor];
        self.rightZi.textColor = [UIColor blackColor];
        self.attention.textColor = [UIColor blackColor];
        self.introduce.textColor = [UIColor blackColor];
        self.zan.textColor = [UIColor blackColor];
        self.name.textColor = [UIColor blackColor];
        self.info.textColor = [UIColor grayColor];

        
    }
    self.img.frame = CGRectMake(0, 0, self.frame.size.width, SAHeight * 200);
    
    //毛玻璃
    self.blur.frame = CGRectMake(0, 0, self.frame.size.width, SAHeight * 200);
    
    self.personImg.frame = CGRectMake(SAWindth * 137, SAHeight * 160, SAWindth * 100, SAHeight * 100);
    self.personImg.layer.cornerRadius = 50;
    self.personImg.layer.masksToBounds = YES;
    
    self.leftImg.frame = CGRectMake(SAWindth * 40, SAHeight * 210, SAWindth * 40, SAHeight * 40);
    self.leftImg.layer.cornerRadius = 20;
    self.leftImg.layer.masksToBounds = YES;
    
    self.rightImg.frame = CGRectMake(SAWindth * 300, SAHeight * 210, SAWindth * 40, SAHeight * 40);
    self.rightImg.layer.cornerRadius = 20;
    self.rightImg.layer.masksToBounds = YES;
    
    self.leftZi.frame = CGRectMake(SAWindth * 40, SAHeight * 260, SAWindth * 20, SAHeight * 20);
    self.leftZi.font = [UIFont systemFontOfSize:15];
    self.zan.frame = CGRectMake(SAWindth * 55, SAHeight * 260, SAWindth * 40, SAHeight * 20);
    self.rightZi.frame = CGRectMake(SAWindth * 290, SAHeight * 260, SAWindth * 40, SAHeight * 20);
    self.rightZi.font = [UIFont systemFontOfSize:15];
    self.attention.frame = CGRectMake(SAWindth * 320, SAHeight * 260, SAWindth * 40, SAHeight * 20);
    self.attention.textAlignment = NSTextAlignmentCenter;
    
    self.name.frame = CGRectMake(SAWindth * 107, SAHeight * 270, SAWindth * 150, SAHeight * 30);
    self.name.textAlignment = NSTextAlignmentCenter;
    self.name.font = [UIFont boldSystemFontOfSize:18];
    
    self.introduce.frame = CGRectMake(SAWindth * 30, SAHeight * 310, SAWindth * 330, SAHeight * 30);
    self.introduce.textAlignment = NSTextAlignmentCenter;
    
    self.info.frame = CGRectMake(SAWindth * 20, SAHeight * 330, SAWindth * 330, SAHeight * 250);
    self.info.textColor = [UIColor grayColor];
    self.info.numberOfLines = 0;
    self.info.textAlignment = NSTextAlignmentCenter;
    self.info.font = [UIFont systemFontOfSize:16];

    
    
    [self.img sd_setImageWithURL:[NSURL URLWithString:self.model.person.avatar] placeholderImage:nil];
    [self.personImg sd_setImageWithURL:[NSURL URLWithString:self.model.person.avatar] placeholderImage:nil];
    self.name.text = self.model.person.name;
    self.zan.text = [NSString stringWithFormat:@"%@", self.model.person.zanCount];
    self.attention.text = [NSString stringWithFormat:@"%@", self.model.person.att_num];
    self.introduce.text = self.model.person.title;
    self.info.text = self.model.person.info;
    
}





/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
